<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>weipinhui</title>
    <style>
        *{
            margin: 0;padding: 0;
        }
        div{
            width: 10rem;height: 200px;
            background-color: yellowgreen;
            color: blue;
            font-size: 50px;
        }
    </style>
</head>

<body>
    <div>注意看看看</div>
</body>
</html>
<script>
    function adpter(){
        // 获取布局视口宽度
        let targetWidth = document.documentElement.clientWidth
        // 将布局视口宽度分十分
        let allRem = 10
        // 得到每一份的大小
        let remFont = targetWidth / allRem
        document.documentElement.style.fontSize=remFont
    }
    adpter()
    window.onreset=adpter
</script>